#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
#define int long long
struct vehic{
	int d,v,acc;
	double ovld;
}a[N];
int p[N],cntdiff[N];
double overload(double v,double acc,double v2){
	return (v2+v)*(v2-v)/(2.00*acc);
}
void solve(){
	int n,m,l,v;
	cin>>n>>m>>l>>v;
	for(int i=1;i<=n;i++){
		scanf("%lld%lld%lld",&a[i].d,&a[i].v,&a[i].acc);
	}
	for(int i=1;i<=m;i++)scanf("%lld",p+i);
	int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i].acc==0){
			cout<<"a"<<endl;
			if(a[i].v>v){
				int k=lower_bound(p+1,p+m+1,a[i].d)-p;
				cntdiff[k]++;
				cntdiff[m+1]--;
			}
		}
		else if(a[i].acc>0){
			double d=overload(a[i].v,a[i].acc,v)+a[i].d;
			int d2=ceil(d);
			int k=lower_bound(p+1,p+m+1,d2)-p;
			if(p[k]==d)++k;
			cntdiff[k]++;
			cntdiff[m+1]--;
		}
		else if(a[i].v>v){
			double d=overload(a[i].v,a[i].acc,v)+a[i].d;
			int d2=ceil(d);
			int k=lower_bound(p+1,p+m+1,a[i].d)-p;
			int kk=lower_bound(p+1,p+m+1,d2)-p;
			cout<<k<<' '<<kk<<endl;
			cntdiff[k]++;
			cntdiff[kk]--;
		}
	}
	int cur=0;
	for(int i=1;i<=m;i++){
		cur+=cntdiff[i];
		ans=max(ans,cur);
	}
	cout<<ans<<' ';
	cur=0,ans=0;
	for(int i=1;i<=m;i++){
		cur+=cntdiff[i];
	}
}//Time Cap. O(NlogN)
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T;
	cin>>T;
	for(int i=1;i<=T;i++)solve();
}
